home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / util / gnu / a2_0bEmacs_bin.lha / Emacs-19.25 / lisp / amiga-mouse.el < prev    next >
Lisp/Scheme  |  1994-08-24  |  40KB  |  1,026 lines

  1. ;;; amiga-mouse.el --- amiga intuition version of mouse.el
  2. ;;; mouse.el claims to provide window system-independent mouse support but
  3. ;;; there are too many X dependancies.
  4.  
  5. ;;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
  6.  
  7. ;; Maintainer: Alph (change to FSF if you like)
  8. ;; Keywords: hardware
  9.  
  10. ;;; This file is part of GNU Emacs.
  11.  
  12. ;;; GNU Emacs is free software; you can redistribute it and/or modify
  13. ;;; it under the terms of the GNU General Public License as published by
  14. ;;; the Free Software Foundation; either version 2, or (at your option)
  15. ;;; any later version.
  16.  
  17. ;;; GNU Emacs is distributed in the hope that it will be useful,
  18. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. ;;; GNU General Public License for more details.
  21.  
  22. ;;; You should have received a copy of the GNU General Public License
  23. ;;; along with GNU Emacs; see the file COPYING.  If not, write to
  24. ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  
  26. ;;; Commentary:
  27.  
  28. ;; This package provides various useful commands (including help
  29. ;; system access) through the mouse.  All this code assumes that mouse
  30. ;; interpretation has been abstracted into Emacs input events.
  31. ;;
  32. ;; The code is not X-dependent.
  33.  
  34. ;;; Code:
  35.  
  36. ;;; Utility functions.
  37.  
  38. ;;; Indent track-mouse like progn.
  39. (put 'track-mouse 'lisp-indent-function 0)
  40.  
  41. (defvar mouse-yank-at-point nil
  42.   "*If non-nil, mouse yank commands yank at point instead of at click.")
  43.  
  44. (defun mouse-minibuffer-check (event)
  45.   (let ((w (posn-window (event-start event))))
  46.     (and (window-minibuffer-p w)
  47.      (not (minibuffer-window-active-p w))
  48.      (error "Minibuffer window is not active"))))
  49.  
  50. (defun mouse-delete-window (click)
  51.   "Delete the window you click on.
  52. This must be bound to a mouse click."
  53.   (interactive "e")
  54.   (mouse-minibuffer-check click)
  55.   (delete-window (posn-window (event-start click))))
  56.  
  57. (defun mouse-select-window (click)
  58.   "Select the window clicked on; don't move point."
  59.   (interactive "e")
  60.   (mouse-minibuffer-check click)
  61.   (let ((oframe (selected-frame))
  62.     (frame (window-frame (posn-window (event-start click)))))
  63.     (select-window (posn-window (event-start click)))
  64.     (raise-frame frame)
  65.     (select-frame frame)
  66.     (or (eq frame oframe)
  67.     (set-mouse-position (selected-frame) (1- (frame-width)) 0))
  68.     (unfocus-frame)))
  69.  
  70. ;(defun mouse-tear-off-window (click)
  71. ;  "Delete the window clicked on, and create a new frame displaying its buffer."
  72. ;  (interactive "e")
  73. ;  (mouse-minibuffer-check click)
  74. ;  (let* ((window (posn-window (event-start click)))
  75. ;     (buf (window-buffer window))
  76. ;     (frame (make-frame)))
  77. ;    (select-frame frame)
  78. ;    (switch-to-buffer buf)
  79. ;    (delete-window window)))
  80.  
  81. (defun mouse-delete-other-windows ()
  82.   "Delete all window except the one you click on."
  83.   (interactive "@")
  84.   (delete-other-windows))
  85.  
  86. (defun mouse-split-window-vertically (click)
  87.   "Select Emacs window mouse is on, then split it vertically in half.
  88. The window is split at the line clicked on.
  89. This command must be bound to a mouse click."
  90.   (interactive "@e")
  91.   (mouse-minibuffer-check click)
  92.   (let ((start (event-start click)))
  93.     (select-window (posn-window start))
  94.     (let ((new-height (1+ (cdr (posn-col-row (event-end click)))))
  95.       (first-line window-min-height)
  96.       (last-line (- (window-height) window-min-height)))
  97.       (if (< last-line first-line)
  98.       (error "window too short to split")
  99.     (split-window-vertically
  100.      (min (max new-height first-line) last-line))))))
  101.  
  102. (defun mouse-split-window-horizontally (click)
  103.   "Select Emacs window mouse is on, then split it horizontally in half.
  104. The window is split at the column clicked on.
  105. This command must be bound to a mouse click."
  106.   (interactive "@e")
  107.   (mouse-minibuffer-check click)
  108.   (let ((start (event-start click)))
  109.     (select-window (posn-window start))
  110.     (let ((new-width (1+ (car (posn-col-row (event-end click)))))
  111.       (first-col window-min-width)
  112.       (last-col (- (window-width) window-min-width)))
  113.       (if (< last-col first-col)
  114.       (error "window too narrow to split")
  115.     (split-window-horizontally
  116.      (min (max new-width first-col) last-col))))))
  117.  
  118. (defun mouse-set-point (event)
  119.   "Move point to the position clicked on with the mouse.
  120. This should be bound to a mouse click event type."
  121.   (interactive "e")
  122.   (mouse-minibuffer-check event)
  123.   ;; Use event-end in case called from mouse-drag-region.
  124.   ;; If EVENT is a click, event-end and event-start give same value.
  125.   (let ((posn (event-end event)))
  126.     (select-window (posn-window posn))
  127.     (if (numberp (posn-point posn))
  128.     (goto-char (posn-point posn)))))
  129.  
  130. (defun mouse-set-region (click)
  131.   "Set the region to the text dragged over, and copy to kill ring.
  132. This should be bound to a mouse drag event."
  133.   (interactive "e")
  134.   (mouse-minibuffer-check click)
  135.   (let ((posn (event-start click))
  136.     (end (event-end click)))
  137.     (select-window (posn-window posn))
  138.     (if (numberp (posn-point posn))
  139.     (goto-char (posn-point posn)))
  140.     ;; If mark is highlighted, no need to bounce the cursor.
  141.     (or (and transient-mark-mode
  142.          (eq (framep (selected-frame)) 'x))
  143.     (sit-for 1))
  144.     (push-mark)
  145.     (set-mark (point))
  146.     (if (numberp (posn-point end))
  147.     (goto-char (posn-point end)))
  148.     ;; Don't set this-command to kill-region, so that a following
  149.     ;; C-w will not double the text in the kill ring.
  150.     (let (this-command)
  151.       (copy-region-as-kill (mark) (point)))))
  152.  
  153. (defvar mouse-scroll-delay 0.25
  154.   "*The pause between scroll steps caused by mouse drags, in seconds.
  155. If you drag the mouse beyond the edge of a window, Emacs scrolls the
  156. window to bring the text beyond that edge into view, with a delay of
  157. this many seconds between scroll steps.  Scrolling stops when you move
  158. the mouse back into the window, or release the button.
  159. This variable's value may be non-integral.
  160. Setting this to zero causes Emacs to scroll as fast as it can.")
  161.  
  162. (defun mouse-scroll-subr (jump &optional overlay start)
  163.   "Scroll the selected window JUMP lines at a time, until new input arrives.
  164. If OVERLAY is an overlay, let it stretch from START to the far edge of
  165. the newly visible text.
  166. Upon exit, point is at the far edge of the newly visible text."
  167.   (while (progn
  168.        (goto-char (window-start))
  169.        (if (not (zerop (vertical-motion jump)))
  170.            (progn
  171.          (set-window-start (selected-window) (point))
  172.          (if (natnump jump)
  173.              (progn
  174.                (goto-char (window-end (selected-window)))
  175.                ;; window-end doesn't reflect the window's new
  176.                ;; start position until the next redisplay.  Hurrah.
  177.                (vertical-motion (1- jump)))
  178.            (goto-char (window-start (selected-window))))
  179.          (if overlay
  180.              (move-overlay overlay start (point)))
  181.          (if (not (eobp))
  182.              (sit-for mouse-scroll-delay))))))
  183.   (point))
  184.  
  185. ; CHFIXME: no dump support for overlays (yet ?)
  186. ;(defvar mouse-drag-overlay (make-overlay 1 1))
  187. ;(overlay-put mouse-drag-overlay 'face 'region)
  188.  
  189. (defvar mouse-selection-click-count 0)
  190.  
  191. (defun mouse-drag-region (start-event)
  192.   "Set the region to the text that the mouse is dragged over.
  193. Highlight the drag area as you move the mouse.
  194. This must be bound to a button-down mouse event.
  195. In Transient Mark mode, the highlighting remains once you
  196. release the mouse button.  Otherwise, it does not."
  197.   (interactive "e")
  198.   (mouse-minibuffer-check start-event)
  199.   (let* ((start-posn (event-start start-event))
  200.      (start-point (posn-point start-posn))
  201.      (start-window (posn-window start-posn))
  202.      (start-frame (window-frame start-window))
  203.      (bounds (window-edges start-window))
  204.      (top (nth 1 bounds))
  205.      (bottom (if (window-minibuffer-p start-window)
  206.              (nth 3 bounds)
  207.            ;; Don't count the mode line.
  208.            (1- (nth 3 bounds))))
  209.      (click-count (1- (event-click-count start-event))))
  210.     (setq mouse-selection-click-count click-count)
  211.     (mouse-set-point start-event)
  212.     (let ((range (mouse-start-end start-point start-point click-count)))
  213.       (move-overlay mouse-drag-overlay (car range) (nth 1 range)
  214.             (window-buffer start-window)))
  215.     (deactivate-mark)
  216.     (let (event end end-point)
  217.       (track-mouse
  218.     (while (progn
  219.          (setq event (read-event))
  220.          (or (mouse-movement-p event)
  221.              (eq (car-safe event) 'switch-frame)))
  222.       (if (eq (car-safe event) 'switch-frame)
  223.           nil
  224.         (setq end (event-end event)
  225.           end-point (posn-point end))
  226.  
  227.         (cond
  228.  
  229.          ;; Ignore switch-frame events.
  230.          ((eq (car-safe event) 'switch-frame))
  231.  
  232.          ;; Are we moving within the original window?
  233.          ((and (eq (posn-window end) start-window)
  234.            (integer-or-marker-p end-point))
  235.           (goto-char end-point)
  236.           (let ((range (mouse-start-end start-point (point) click-count)))
  237.         (move-overlay mouse-drag-overlay (car range) (nth 1 range))))
  238.  
  239.          (t
  240.           (let ((mouse-row (cdr (cdr (mouse-position)))))
  241.         (cond
  242.          ((null mouse-row))
  243.          ((< mouse-row top)
  244.           (mouse-scroll-subr
  245.            (- mouse-row top) mouse-drag-overlay start-point))
  246.          ((and (not (eobp))
  247.                (>= mouse-row bottom))
  248.           (mouse-scroll-subr (1+ (- mouse-row bottom))
  249.                      mouse-drag-overlay start-point)))))))))
  250.  
  251.       (if (and (eq (get (event-basic-type event) 'event-kind) 'mouse-click)
  252.            (eq (posn-window (event-end event)) start-window)
  253.            (numberp (posn-point (event-end event))))
  254.       (let ((fun (key-binding (vector (car event)))))
  255.         (if (memq fun '(mouse-set-region mouse-set-point))
  256.         (if (not (= (overlay-start mouse-drag-overlay)
  257.                 (overlay-end mouse-drag-overlay)))
  258.             (let (this-command)
  259.               (push-mark (overlay-start mouse-drag-overlay) t t)
  260.               (goto-char (overlay-end mouse-drag-overlay))
  261.               (copy-region-as-kill (point) (mark t)))
  262.           (goto-char (overlay-end mouse-drag-overlay))
  263.           (setq this-command 'mouse-set-point))
  264.           (if (fboundp fun)
  265.           (funcall fun event)))))
  266.       (delete-overlay mouse-drag-overlay))))
  267.  
  268. ;; Commands to handle xterm-style multiple clicks.
  269.  
  270. (defun mouse-skip-word (dir)
  271.   "Skip over word, over whitespace, or over identical punctuation.
  272. If DIR is positive skip forward; if negative, skip backward."
  273.   (let* ((char (following-char))
  274.      (syntax (char-to-string (char-syntax char))))
  275.     (if (or (string= syntax "w") (string= syntax " "))
  276.     (if (< dir 0)
  277.         (skip-syntax-backward syntax)
  278.       (skip-syntax-forward syntax))
  279.       (if (< dir 0)
  280.       (while (and (not (bobp)) (= (preceding-char) char))
  281.         (forward-char -1))
  282.     (while (and (not (eobp)) (= (following-char) char))
  283.       (forward-char 1))))))
  284.  
  285. ;; Return a list of region bounds based on START and END according to MODE.
  286. ;; If MODE is 0 then set point to (min START END), mark to (max START END).
  287. ;; If MODE is 1 then set point to start of word at (min START END),
  288. ;; mark to end of word at (max START END).
  289. ;; If MODE is 2 then do the same for lines.
  290. (defun mouse-start-end (start end mode)
  291.   (if (> start end)
  292.       (let ((temp start))
  293.         (setq start end
  294.               end temp)))
  295.   (setq mode (mod mode 3))
  296.   (cond ((= mode 0)
  297.      (list start end))
  298.         ((and (= mode 1)
  299.               (= start end)
  300.           (char-after start)
  301.               (= (char-syntax (char-after start)) ?\())
  302.      (list start
  303.            (save-excursion
  304.          (goto-char start)
  305.          (forward-sexp 1)
  306.          (point))))
  307.         ((and (= mode 1)
  308.               (= start end)
  309.           (char-after start)
  310.               (= (char-syntax (char-after start)) ?\)))
  311.      (list (save-excursion 
  312.          (goto-char (1+ start))
  313.          (backward-sexp 1)
  314.          (point))
  315.            (1+ start)))
  316.         ((= mode 1)
  317.      (list (save-excursion
  318.          (goto-char start)
  319.          (mouse-skip-word -1)
  320.          (point))
  321.            (save-excursion
  322.          (goto-char end)
  323.          (mouse-skip-word 1)
  324.          (point))))
  325.         ((= mode 2)
  326.      (list (save-excursion
  327.          (goto-char start)
  328.          (beginning-of-line 1)
  329.          (point))
  330.            (save-excursion
  331.          (goto-char end)
  332.          (forward-line 1)
  333.          (point))))))
  334.  
  335. ;; Subroutine: set the mark where CLICK happened,
  336. ;; but don't do anything else.
  337. (defun mouse-set-mark-fast (click)
  338.   (mouse-minibuffer-check click)
  339.   (let ((posn (event-start click)))
  340.     (select-window (posn-window posn))
  341.     (if (numberp (posn-point posn))
  342.     (push-mark (posn-point posn) t t))))
  343.  
  344. ;; Momentarily show where the mark is, if highlighting doesn't show it. 
  345. (defun mouse-show-mark ()
  346.   (or transient-mark-mode
  347.       (save-excursion
  348.     (goto-char (mark t))
  349.     (sit-for 1))))
  350.  
  351. (defun mouse-set-mark (click)
  352.   "Set mark at the position clicked on with the mouse.
  353. Display cursor at that position for a second.
  354. This must be bound to a mouse click."
  355.   (interactive "e")
  356.   (let ((point-save (point)))
  357.     (unwind-protect
  358.     (progn (mouse-set-point click)
  359.            (push-mark nil t t)
  360.            (or transient-mark-mode
  361.            (sit-for 1)))
  362.       (goto-char point-save))))
  363.  
  364. (defun mouse-kill (click)
  365.   "Kill the region between point and the mouse click.
  366. The text is saved in the kill ring, as with \\[kill-region]."
  367.   (interactive "e")
  368.   (mouse-minibuffer-check click)
  369.   (let* ((posn (event-start click))
  370.      (click-posn (posn-point posn)))
  371.     (select-window (posn-window posn))
  372.     (if (numberp click-posn)
  373.     (kill-region (min (point) click-posn)
  374.              (max (point) click-posn)))))
  375.  
  376. (defun mouse-yank-at-click (click arg)
  377.   "Insert the last stretch of killed text at the position clicked on.
  378. Also move point to one end of the text thus inserted (normally the end).
  379. Prefix arguments are interpreted as with \\[yank].
  380. If `mouse-yank-at-point' is non-nil, insert at point
  381. regardless of where you click."
  382.   (interactive "e\nP")
  383.   (or mouse-yank-at-point (mouse-set-point click))
  384.   (setq this-command 'yank)
  385.   (yank arg))
  386.  
  387. (defun mouse-kill-ring-save (click)
  388.   "Copy the region between point and the mouse click in the kill ring.
  389. This does not delete the region; it acts like \\[kill-ring-save]."
  390.   (interactive "e")
  391.   (mouse-set-mark-fast click)
  392.   (kill-ring-save (point) (mark t))
  393.   (mouse-show-mark))
  394.  
  395. ;;; This function used to delete the text between point and the mouse
  396. ;;; whenever it was equal to the front of the kill ring, but some
  397. ;;; people found that confusing.
  398.  
  399. ;;; A list (TEXT START END), describing the text and position of the last
  400. ;;; invocation of mouse-save-then-kill.
  401. (defvar mouse-save-then-kill-posn nil)
  402.  
  403. (defun mouse-save-then-kill-delete-region (beg end)
  404.   ;; We must make our own undo boundaries
  405.   ;; because they happen automatically only for the current buffer.
  406.   (undo-boundary)
  407.   (if (or (= beg end) (eq buffer-undo-list t))
  408.       ;; If we have no undo list in this buffer,
  409.       ;; just delete.
  410.       (delete-region beg end)
  411.     ;; Delete, but make the undo-list entry share with the kill ring.
  412.     ;; First, delete just one char, so in case buffer is being modified
  413.     ;; for the first time, the undo list records that fact.
  414.     (delete-region beg
  415.            (+ beg (if (> end beg) 1 -1)))
  416.     (let ((buffer-undo-list buffer-undo-list))
  417.       ;; Undo that deletion--but don't change the undo list!
  418.       (primitive-undo 1 buffer-undo-list)
  419.       ;; Now delete the rest of the specified region,
  420.       ;; but don't record it.
  421.       (setq buffer-undo-list t)
  422.       (if (/= (length (car kill-ring)) (- (max end beg) (min end beg)))
  423.       (error "Lossage in mouse-save-then-kill-delete-region"))
  424.       (delete-region beg end))
  425.     (let ((tail buffer-undo-list))
  426.       ;; Search back in buffer-undo-list for the string
  427.       ;; that came from deleting one character.
  428.       (while (and tail (not (stringp (car (car tail)))))
  429.     (setq tail (cdr tail)))
  430.       ;; Replace it with an entry for the entire deleted text.
  431.       (and tail
  432.        (setcar tail (cons (car kill-ring) (min beg end))))))
  433.   (undo-boundary))
  434.  
  435. (defun mouse-save-then-kill (click)
  436.   "Save text to point in kill ring; the second time, kill the text.
  437. If the text between point and the mouse is the same as what's
  438. at the front of the kill ring, this deletes the text.
  439. Otherwise, it adds the text to the kill ring, like \\[kill-ring-save],
  440. which prepares for a second click to delete the text.
  441.  
  442. If you have selected words or lines, this command extends the
  443. selection through the word or line clicked on.  If you do this
  444. again in a different position, it extends the selection again.
  445. If you do this twice in the same position, the selection is killed." 
  446.   (interactive "e")
  447.   (mouse-minibuffer-check click)
  448.   (let ((click-posn (posn-point (event-start click)))
  449.     ;; Don't let a subsequent kill command append to this one:
  450.     ;; prevent setting this-command to kill-region.
  451.     (this-command this-command))
  452.     (if (> (mod mouse-selection-click-count 3) 0)
  453.     (if (not (and (eq last-command 'mouse-save-then-kill)
  454.               (equal click-posn
  455.                  (car (cdr-safe (cdr-safe mouse-save-then-kill-posn))))))
  456.         ;; Find both ends of the object selected by this click.
  457.         (let* ((range
  458.             (mouse-start-end click-posn click-posn
  459.                      mouse-selection-click-count)))
  460.           ;; Move whichever end is closer to the click.
  461.           ;; That's what xterm does, and it seems reasonable.
  462.           (if (< (abs (- click-posn (mark t)))
  463.              (abs (- click-posn (point))))
  464.           (set-mark (car range))
  465.         (goto-char (nth 1 range)))
  466.           ;; We have already put the old region in the kill ring.
  467.           ;; Replace it with the extended region.
  468.           ;; (It would be annoying to make a separate entry.)
  469.           (setcar kill-ring (buffer-substring (point) (mark t)))
  470.           (if interprogram-cut-function
  471.           (funcall interprogram-cut-function (car kill-ring)))
  472.           ;; Arrange for a repeated mouse-3 to kill this region.
  473.           (setq mouse-save-then-kill-posn
  474.             (list (car kill-ring) (point) click-posn))
  475.           (mouse-show-mark))
  476.       ;; If we click this button again without moving it,
  477.       ;; that time kill.
  478.       (mouse-save-then-kill-delete-region (point) (mark))
  479.       (setq mouse-selection-click-count 0)
  480.       (setq mouse-save-then-kill-posn nil))
  481.       (if (and (eq last-command 'mouse-save-then-kill)
  482.            mouse-save-then-kill-posn
  483.            (eq (car mouse-save-then-kill-posn) (car kill-ring))
  484.            (equal (cdr mouse-save-then-kill-posn) (list (point) click-posn)))
  485.       ;; If this is the second time we've called
  486.       ;; mouse-save-then-kill, delete the text from the buffer.
  487.       (progn
  488.         (mouse-save-then-kill-delete-region (point) (mark))
  489.         ;; After we kill, another click counts as "the first time".
  490.         (setq mouse-save-then-kill-posn nil))
  491.     (if (or (and (eq last-command 'mouse-save-then-kill)
  492.              mouse-save-then-kill-posn)
  493.         (and mark-active transient-mark-mode)
  494.         (and (eq last-command 'mouse-drag-region)
  495.              (or mark-even-if-inactive
  496.              (not transient-mark-mode))))
  497.         ;; We have a selection or suitable region, so adjust it.
  498.         (let* ((posn (event-start click))
  499.            (new (posn-point posn)))
  500.           (select-window (posn-window posn))
  501.           (if (numberp new)
  502.           (progn
  503.             ;; Move whichever end of the region is closer to the click.
  504.             ;; That is what xterm does, and it seems reasonable.
  505.             (if (< (abs (- new (point))) (abs (- new (mark t))))
  506.             (goto-char new)
  507.               (set-mark new))
  508.             (setq deactivate-mark nil)))
  509.           (setcar kill-ring (buffer-substring (point) (mark t)))
  510.           (if interprogram-cut-function
  511.           (funcall interprogram-cut-function (car kill-ring))))
  512.       ;; We just have point, so set mark here.
  513.       (mouse-set-mark-fast click)
  514.       (kill-ring-save (point) (mark t))
  515.       (mouse-show-mark))
  516.     (setq mouse-save-then-kill-posn
  517.           (list (car kill-ring) (point) click-posn))))))
  518.  
  519. ;(global-set-key [M-mouse-1] 'mouse-start-secondary)
  520. ;(global-set-key [M-drag-mouse-1] 'mouse-set-secondary)
  521. ;(global-set-key [M-down-mouse-1] 'mouse-drag-secondary)
  522. ;(global-set-key [M-mouse-3] 'mouse-secondary-save-then-kill)
  523. ;(global-set-key [M-mouse-2] 'mouse-yank-secondary)
  524.  
  525. ;;
  526. ;; CHFIXME no secondary (add clipboard support here?)
  527. ;;
  528.  
  529. ;; An overlay which records the current secondary selection
  530. ;; or else is deleted when there is no secondary selection.
  531. ;; May be nil.
  532. ;(defvar mouse-secondary-overlay nil)
  533.  
  534. ;; A marker which records the specified first end for a secondary selection.
  535. ;; May be nil.
  536. ;(defvar mouse-secondary-start nil)
  537. ;
  538. ;(defun mouse-start-secondary (click)
  539. ;  "Set one end of the secondary selection to the position clicked on.
  540. ;Use \\[mouse-secondary-save-then-kill] to set the other end
  541. ;and complete the secondary selection."
  542. ;  (interactive "e")
  543. ;  (mouse-minibuffer-check click)
  544. ;  (let ((posn (event-start click)))
  545. ;    (save-excursion
  546. ;      (set-buffer (window-buffer (posn-window posn)))
  547. ;      ;; Cancel any preexisting secondary selection.
  548. ;      (if mouse-secondary-overlay
  549. ;      (delete-overlay mouse-secondary-overlay))
  550. ;      (if (numberp (posn-point posn))
  551. ;      (progn
  552. ;        (or mouse-secondary-start
  553. ;        (setq mouse-secondary-start (make-marker)))
  554. ;        (move-marker mouse-secondary-start (posn-point posn)))))))
  555. ;
  556. ;(defun mouse-set-secondary (click)
  557. ;  "Set the secondary selection to the text that the mouse is dragged over.
  558. ;This must be bound to a mouse drag event."
  559. ;  (interactive "e")
  560. ;  (mouse-minibuffer-check click)
  561. ;  (let ((posn (event-start click))
  562. ;    beg
  563. ;    (end (event-end click)))
  564. ;    (save-excursion
  565. ;      (set-buffer (window-buffer (posn-window posn)))
  566. ;      (if (numberp (posn-point posn))
  567. ;      (setq beg (posn-point posn)))
  568. ;      (if mouse-secondary-overlay
  569. ;      (move-overlay mouse-secondary-overlay beg (posn-point end))
  570. ;    (setq mouse-secondary-overlay (make-overlay beg (posn-point end))))
  571. ;      (overlay-put mouse-secondary-overlay 'face 'secondary-selection))))
  572. ;
  573. ;(defun mouse-drag-secondary (start-event)
  574. ;  "Set the secondary selection to the text that the mouse is dragged over.
  575. ;Highlight the drag area as you move the mouse.
  576. ;This must be bound to a button-down mouse event."
  577. ;  (interactive "e")
  578. ;  (mouse-minibuffer-check start-event)
  579. ;  (let* ((start-posn (event-start start-event))
  580. ;     (start-point (posn-point start-posn))
  581. ;     (start-window (posn-window start-posn))
  582. ;     (start-frame (window-frame start-window))
  583. ;     (bounds (window-edges start-window))
  584. ;     (top (nth 1 bounds))
  585. ;     (bottom (if (window-minibuffer-p start-window)
  586. ;             (nth 3 bounds)
  587. ;           ;; Don't count the mode line.
  588. ;           (1- (nth 3 bounds))))
  589. ;     (click-count (1- (event-click-count start-event))))
  590. ;    (save-excursion
  591. ;      (set-buffer (window-buffer start-window))
  592. ;      (setq mouse-selection-click-count click-count)
  593. ;      (or mouse-secondary-overlay
  594. ;      (setq mouse-secondary-overlay
  595. ;        (make-overlay (point) (point))))
  596. ;      (overlay-put mouse-secondary-overlay 'face 'secondary-selection)
  597. ;      (if (> (mod click-count 3) 0)
  598. ;      ;; Double or triple press: make an initial selection
  599. ;      ;; of one word or line.
  600. ;      (let ((range (mouse-start-end start-point start-point click-count)))
  601. ;        (set-marker mouse-secondary-start nil)
  602. ;        (move-overlay mouse-secondary-overlay 1 1
  603. ;              (window-buffer start-window))
  604. ;        (move-overlay mouse-secondary-overlay (car range) (nth 1 range)
  605. ;              (window-buffer start-window)))
  606. ;    ;; Single-press: cancel any preexisting secondary selection.
  607. ;    (or mouse-secondary-start
  608. ;        (setq mouse-secondary-start (make-marker)))
  609. ;    (set-marker mouse-secondary-start start-point)
  610. ;    (delete-overlay mouse-secondary-overlay))
  611. ;      (let (event end end-point)
  612. ;    (track-mouse
  613. ;      (while (progn
  614. ;           (setq event (read-event))
  615. ;           (or (mouse-movement-p event)
  616. ;               (eq (car-safe event) 'switch-frame)))
  617. ;
  618. ;        (if (eq (car-safe event) 'switch-frame)
  619. ;        nil
  620. ;          (setq end (event-end event)
  621. ;            end-point (posn-point end))
  622. ;          (cond
  623. ;
  624. ;           ;; Ignore switch-frame events.
  625. ;           ((eq (car-safe event) 'switch-frame))
  626. ;
  627. ;           ;; Are we moving within the original window?
  628. ;           ((and (eq (posn-window end) start-window)
  629. ;             (integer-or-marker-p end-point))
  630. ;        (if (/= start-point end-point)
  631. ;            (set-marker mouse-secondary-start nil))
  632. ;        (let ((range (mouse-start-end start-point end-point
  633. ;                          click-count)))
  634. ;          (move-overlay mouse-secondary-overlay
  635. ;                (car range) (nth 1 range))))
  636. ;               (t
  637. ;                (let ((mouse-row (cdr (cdr (mouse-position)))))
  638. ;                  (cond
  639. ;                   ((null mouse-row))
  640. ;                   ((< mouse-row top)
  641. ;                    (mouse-scroll-subr
  642. ;                     (- mouse-row top) mouse-secondary-overlay start-point))
  643. ;                   ((and (not (eobp))
  644. ;                         (>= mouse-row bottom))
  645. ;                    (mouse-scroll-subr (1+ (- mouse-row bottom))
  646. ;                                       mouse-secondary-overlay start-point)))))))))
  647. ;
  648. ;    (if (and (eq (get (event-basic-type event) 'event-kind) 'mouse-click)
  649. ;         (eq (posn-window (event-end event)) start-window)
  650. ;         (numberp (posn-point (event-end event))))
  651. ;        (if (marker-position mouse-secondary-start)
  652. ;        (save-window-excursion
  653. ;          (delete-overlay mouse-secondary-overlay)
  654. ;          (x-set-selection 'SECONDARY nil)
  655. ;          (select-window start-window)
  656. ;          (save-excursion
  657. ;            (goto-char mouse-secondary-start)
  658. ;            (sit-for 1)))
  659. ;          (x-set-selection
  660. ;           'SECONDARY
  661. ;           (buffer-substring (overlay-start mouse-secondary-overlay)
  662. ;                 (overlay-end mouse-secondary-overlay)))))))))
  663. ;
  664. ;(defun mouse-yank-secondary (click)
  665. ;  "Insert the secondary selection at the position clicked on.
  666. ;Move point to the end of the inserted text.
  667. ;If `mouse-yank-at-point' is non-nil, insert at point
  668. ;regardless of where you click."
  669. ;  (interactive "e")
  670. ;  (or mouse-yank-at-point (mouse-set-point click))
  671. ;  (insert (x-get-selection 'SECONDARY)))
  672. ;
  673. ;(defun mouse-kill-secondary ()
  674. ;  "Kill the text in the secondary selection.
  675. ;This is intended more as a keyboard command than as a mouse command
  676. ;but it can work as either one.
  677. ;
  678. ;The current buffer (in case of keyboard use), or the buffer clicked on,
  679. ;must be the one that the secondary selection is in.  This requirement
  680. ;is to prevent accidents."
  681. ;  (interactive)
  682. ;  (let* ((keys (this-command-keys))
  683. ;     (click (elt keys (1- (length keys)))))
  684. ;    (or (eq (overlay-buffer mouse-secondary-overlay)
  685. ;        (if (listp click)
  686. ;        (window-buffer (posn-window (event-start click)))
  687. ;          (current-buffer)))
  688. ;    (error "Select or click on the buffer where the secondary selection is")))
  689. ;  (save-excursion
  690. ;    (set-buffer (overlay-buffer mouse-secondary-overlay))
  691. ;    (kill-region (overlay-start mouse-secondary-overlay)
  692. ;         (overlay-end mouse-secondary-overlay)))
  693. ;  (delete-overlay mouse-secondary-overlay)
  694. ;  (x-set-selection 'SECONDARY nil)
  695. ;  (setq mouse-secondary-overlay nil))
  696. ;
  697. ;(defun mouse-secondary-save-then-kill (click)
  698. ;  "Save text to point in kill ring; the second time, kill the text.
  699. ;You must use this in a buffer where you have recently done \\[mouse-start-secondary].
  700. ;If the text between where you did \\[mouse-start-secondary] and where
  701. ;you use this command matches the text at the front of the kill ring,
  702. ;this command deletes the text.
  703. ;Otherwise, it adds the text to the kill ring, like \\[kill-ring-save],
  704. ;which prepares for a second click with this command to delete the text.
  705. ;
  706. ;If you have already made a secondary selection in that buffer,
  707. ;this command extends or retracts the selection to where you click.
  708. ;If you do this again in a different position, it extends or retracts
  709. ;again.  If you do this twice in the same position, it kills the selection."
  710. ;  (interactive "e")
  711. ;  (mouse-minibuffer-check click)
  712. ;  (let ((posn (event-start click))
  713. ;    (click-posn (posn-point (event-start click)))
  714. ;    ;; Don't let a subsequent kill command append to this one:
  715. ;    ;; prevent setting this-command to kill-region.
  716. ;    (this-command this-command))
  717. ;    (or (eq (window-buffer (posn-window posn))
  718. ;        (or (and mouse-secondary-overlay
  719. ;             (overlay-buffer mouse-secondary-overlay))
  720. ;        (if mouse-secondary-start
  721. ;            (marker-buffer mouse-secondary-start))))
  722. ;    (error "Wrong buffer"))
  723. ;    (save-excursion
  724. ;      (set-buffer (window-buffer (posn-window posn)))
  725. ;      (if (> (mod mouse-selection-click-count 3) 0)
  726. ;      (if (not (and (eq last-command 'mouse-secondary-save-then-kill)
  727. ;            (equal click-posn
  728. ;                   (car (cdr-safe (cdr-safe mouse-save-then-kill-posn))))))
  729. ;          ;; Find both ends of the object selected by this click.
  730. ;          (let* ((range
  731. ;              (mouse-start-end click-posn click-posn
  732. ;                       mouse-selection-click-count)))
  733. ;        ;; Move whichever end is closer to the click.
  734. ;        ;; That's what xterm does, and it seems reasonable.
  735. ;        (if (< (abs (- click-posn (overlay-start mouse-secondary-overlay)))
  736. ;               (abs (- click-posn (overlay-end mouse-secondary-overlay))))
  737. ;            (move-overlay mouse-secondary-overlay (car range)
  738. ;                  (overlay-end mouse-secondary-overlay))
  739. ;          (move-overlay mouse-secondary-overlay
  740. ;                (overlay-start mouse-secondary-overlay)
  741. ;                (nth 1 range)))
  742. ;        ;; We have already put the old region in the kill ring.
  743. ;        ;; Replace it with the extended region.
  744. ;        ;; (It would be annoying to make a separate entry.)
  745. ;        (setcar kill-ring (buffer-substring
  746. ;                   (overlay-start mouse-secondary-overlay)
  747. ;                   (overlay-end mouse-secondary-overlay)))
  748. ;        (if interprogram-cut-function
  749. ;            (funcall interprogram-cut-function (car kill-ring)))
  750. ;        ;; Arrange for a repeated mouse-3 to kill this region.
  751. ;        (setq mouse-save-then-kill-posn
  752. ;              (list (car kill-ring) (point) click-posn)))
  753. ;        ;; If we click this button again without moving it,
  754. ;        ;; that time kill.
  755. ;        (progn
  756. ;          (mouse-save-then-kill-delete-region
  757. ;           (overlay-start mouse-secondary-overlay)
  758. ;           (overlay-end mouse-secondary-overlay))
  759. ;          (setq mouse-save-then-kill-posn nil)
  760. ;          (setq mouse-selection-click-count 0)
  761. ;          (delete-overlay mouse-secondary-overlay)))
  762. ;    (if (and (eq last-command 'mouse-secondary-save-then-kill)
  763. ;         mouse-save-then-kill-posn
  764. ;         (eq (car mouse-save-then-kill-posn) (car kill-ring))
  765. ;         (equal (cdr mouse-save-then-kill-posn) (list (point) click-posn)))
  766. ;        ;; If this is the second time we've called
  767. ;        ;; mouse-secondary-save-then-kill, delete the text from the buffer.
  768. ;        (progn
  769. ;          (mouse-save-then-kill-delete-region
  770. ;           (overlay-start mouse-secondary-overlay)
  771. ;           (overlay-end mouse-secondary-overlay))
  772. ;          (setq mouse-save-then-kill-posn nil)
  773. ;          (delete-overlay mouse-secondary-overlay))
  774. ;      (if (overlay-start mouse-secondary-overlay)
  775. ;          ;; We have a selection, so adjust it.
  776. ;          (progn
  777. ;        (if (numberp click-posn)
  778. ;            (progn
  779. ;              ;; Move whichever end of the region is closer to the click.
  780. ;              ;; That is what xterm does, and it seems reasonable.
  781. ;              (if (< (abs (- click-posn (overlay-start mouse-secondary-overlay)))
  782. ;                 (abs (- click-posn (overlay-end mouse-secondary-overlay))))
  783. ;              (move-overlay mouse-secondary-overlay click-posn
  784. ;                    (overlay-end mouse-secondary-overlay))
  785. ;            (move-overlay mouse-secondary-overlay
  786. ;                      (overlay-start mouse-secondary-overlay)
  787. ;                      click-posn))
  788. ;              (setq deactivate-mark nil)))
  789. ;        (setcar kill-ring (buffer-substring
  790. ;                   (overlay-start mouse-secondary-overlay)
  791. ;                   (overlay-end mouse-secondary-overlay)))
  792. ;        (if interprogram-cut-function
  793. ;            (funcall interprogram-cut-function (car kill-ring))))
  794. ;        (if mouse-secondary-start
  795. ;        ;; All we have is one end of a selection,
  796. ;        ;; so put the other end here.
  797. ;        (let ((start (+ 0 mouse-secondary-start)))
  798. ;          (kill-ring-save start click-posn)
  799. ;          (if mouse-secondary-overlay
  800. ;              (move-overlay mouse-secondary-overlay start click-posn)
  801. ;            (setq mouse-secondary-overlay (make-overlay start click-posn)))
  802. ;          (overlay-put mouse-secondary-overlay 'face 'secondary-selection))))
  803. ;      (setq mouse-save-then-kill-posn
  804. ;        (list (car kill-ring) (point) click-posn))))
  805. ;      (x-set-selection 'SECONDARY
  806. ;               (if (overlay-buffer mouse-secondary-overlay)
  807. ;               (buffer-substring
  808. ;                (overlay-start mouse-secondary-overlay)
  809. ;                (overlay-end mouse-secondary-overlay)))))))
  810.  
  811. ; CHFIXME: no menus yet
  812.  
  813. ;(defun mouse-buffer-menu (event)
  814. ;  "Pop up a menu of buffers for selection with the mouse.
  815. ;This switches buffers in the window that you clicked on,
  816. ;and selects that window."
  817. ;  (interactive "e")
  818. ;  (mouse-minibuffer-check event)
  819. ;  (let ((menu
  820. ;     (list "Buffer Menu"
  821. ;           (cons "Select Buffer"
  822. ;             (let ((tail (buffer-list))
  823. ;               (maxbuf 0)
  824. ;               head)
  825. ;               (while tail
  826. ;             (or (eq ?\ (aref (buffer-name (car tail)) 0))
  827. ;                 (setq maxbuf
  828. ;                   (max maxbuf
  829. ;                    (length (buffer-name (car tail))))))
  830. ;             (setq tail (cdr tail)))
  831. ;               (setq tail (buffer-list))
  832. ;               (while tail
  833. ;             (let ((elt (car tail)))
  834. ;               (if (not (string-match "^ "
  835. ;                          (buffer-name elt)))
  836. ;                   (setq head (cons
  837. ;                       (cons
  838. ;                        (format
  839. ;                         (format "%%%ds  %%s%%s  %%s"
  840. ;                             maxbuf)
  841. ;                         (buffer-name elt)
  842. ;                         (if (buffer-modified-p elt)
  843. ;                         "*" " ")
  844. ;                         (save-excursion
  845. ;                           (set-buffer elt)
  846. ;                           (if buffer-read-only "%" " "))
  847. ;                         (or (buffer-file-name elt) ""))
  848. ;                        elt)
  849. ;                       head))))
  850. ;             (setq tail (cdr tail)))
  851. ;               (reverse head))))))
  852. ;    (let ((buf (x-popup-menu event menu))
  853. ;      (window (posn-window (event-start event))))
  854. ;      (if buf
  855. ;      (progn
  856. ;        (or (framep window) (select-window window))
  857. ;        (switch-to-buffer buf))))))
  858.  
  859. ;; Choose a completion with the mouse.
  860.  
  861. (defun mouse-choose-completion (event)
  862.   "Click on an alternative in the `*Completions*' buffer to choose it."
  863.   (interactive "e")
  864.   (let ((buffer (window-buffer))
  865.         choice)
  866.     (save-excursion
  867.       (set-buffer (window-buffer (posn-window (event-start event))))
  868.       (if completion-reference-buffer
  869.       (setq buffer completion-reference-buffer))
  870.       (save-excursion
  871.     (goto-char (posn-point (event-start event)))
  872.     (let (beg end)
  873.       (skip-chars-forward "^ \t\n")
  874.       (while (looking-at " [^ \n\t]")
  875.         (forward-char 1)
  876.         (skip-chars-forward "^ \t\n"))
  877.       (setq end (point))
  878.       (skip-chars-backward "^ \t\n")
  879.       (while (and (= (preceding-char) ?\ )
  880.               (not (and (> (point) (1+ (point-min)))
  881.                 (= (char-after (- (point) 2)) ?\ ))))
  882.         (backward-char 1)
  883.         (skip-chars-backward "^ \t\n"))
  884.       (setq beg (point))
  885.       (setq choice (buffer-substring beg end)))))
  886.     (let ((owindow (selected-window)))
  887.       (select-window (posn-window (event-start event)))
  888.       (bury-buffer)
  889.       (select-window owindow))
  890.     (choose-completion-string choice buffer)))
  891.  
  892. ;; Font selection.
  893.  
  894. ;(defun font-menu-add-default ()
  895. ;  (let* ((default (cdr (assq 'font (frame-parameters (selected-frame)))))
  896. ;     (font-alist x-fixed-font-alist)
  897. ;     (elt (or (assoc "Misc" font-alist) (nth 1 font-alist))))
  898. ;    (if (assoc "Default" elt)
  899. ;    (delete (assoc "Default" elt) elt))
  900. ;    (setcdr elt
  901. ;        (cons (list "Default"
  902. ;            (cdr (assq 'font (frame-parameters (selected-frame)))))
  903. ;          (cdr elt)))))
  904. ;
  905. ;(defvar x-fixed-font-alist
  906. ;  '("Font menu"
  907. ;    ("Misc"
  908. ;     ("6x10" "-misc-fixed-medium-r-normal--10-100-75-75-c-60-*-1" "6x10")
  909. ;     ("6x12" "-misc-fixed-medium-r-semicondensed--12-110-75-75-c-60-*-1" "6x12")
  910. ;     ("6x13" "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-1" "6x13")
  911. ;     ("lucida 13"
  912. ;      "-b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-*-1")
  913. ;     ("7x13" "-misc-fixed-medium-r-normal--13-120-75-75-c-70-*-1" "7x13")
  914. ;     ("7x14" "-misc-fixed-medium-r-normal--14-130-75-75-c-70-*-1" "7x14")
  915. ;     ("9x15" "-misc-fixed-medium-r-normal--15-140-*-*-c-*-*-1" "9x15")
  916. ;     ("")
  917. ;     ("clean 8x8" "-schumacher-clean-medium-r-normal--*-80-*-*-c-*-*-1")
  918. ;     ("clean 8x14" "-schumacher-clean-medium-r-normal--*-140-*-*-c-*-*-1")
  919. ;     ("clean 8x10" "-schumacher-clean-medium-r-normal--*-100-*-*-c-*-*-1")
  920. ;     ("clean 8x16" "-schumacher-clean-medium-r-normal--*-160-*-*-c-*-*-1")
  921. ;     ("")
  922. ;     ("sony 8x16" "-sony-fixed-medium-r-normal--16-120-100-100-c-80-*-1")
  923. ;     ("")
  924. ;     ("fixed" "fixed")
  925. ;     ("10x20" "10x20")
  926. ;     ("11x18" "11x18")
  927. ;     ("12x24" "12x24"))
  928. ;;;; We don't seem to have these; who knows what they are.
  929. ;;;;    ("fg-18" "fg-18")
  930. ;;;;    ("fg-25" "fg-25")
  931. ;;;;    ("lucidasanstypewriter-12" "lucidasanstypewriter-12")
  932. ;;;;    ("lucidasanstypewriter-bold-14" "lucidasanstypewriter-bold-14")
  933. ;;;;    ("lucidasanstypewriter-bold-24" "lucidasanstypewriter-bold-24")
  934. ;;;;    ("lucidatypewriter-bold-r-24" "-b&h-lucidatypewriter-bold-r-normal-sans-24-240-75-75-m-140-iso8859-1")
  935. ;;;;    ("fixed-medium-20" "-misc-fixed-medium-*-*-*-20-*-*-*-*-*-*-*")
  936. ;    ("Courier"
  937. ;     ("8" "-adobe-courier-medium-r-normal--*-80-*-*-m-*-iso8859-1")
  938. ;     ("10" "-adobe-courier-medium-r-normal--*-100-*-*-m-*-iso8859-1")
  939. ;     ("12" "-adobe-courier-medium-r-normal--*-120-*-*-m-*-iso8859-1")
  940. ;     ("14" "-adobe-courier-medium-r-normal--*-140-*-*-m-*-iso8859-1")
  941. ;     ("18" "-adobe-courier-medium-r-normal--*-180-*-*-m-*-iso8859-1")
  942. ;     ("24" "-adobe-courier-medium-r-normal--*-240-*-*-m-*-iso8859-1")
  943. ;     ("8 bold" "-adobe-courier-bold-r-normal--*-80-*-*-m-*-iso8859-1")
  944. ;     ("10 bold" "-adobe-courier-bold-r-normal--*-100-*-*-m-*-iso8859-1")
  945. ;     ("12 bold" "-adobe-courier-bold-r-normal--*-120-*-*-m-*-iso8859-1")
  946. ;     ("14 bold" "-adobe-courier-bold-r-normal--*-140-*-*-m-*-iso8859-1")
  947. ;     ("18 bold" "-adobe-courier-bold-r-normal--*-180-*-*-m-*-iso8859-1")
  948. ;     ("24 bold" "-adobe-courier-bold-r-normal--*-240-*-*-m-*-iso8859-1")
  949. ;     ("8 slant" "-adobe-courier-medium-o-normal--*-80-*-*-m-*-iso8859-1")
  950. ;     ("10 slant" "-adobe-courier-medium-o-normal--*-100-*-*-m-*-iso8859-1")
  951. ;     ("12 slant" "-adobe-courier-medium-o-normal--*-120-*-*-m-*-iso8859-1")
  952. ;     ("14 slant" "-adobe-courier-medium-o-normal--*-140-*-*-m-*-iso8859-1")
  953. ;     ("18 slant" "-adobe-courier-medium-o-normal--*-180-*-*-m-*-iso8859-1")
  954. ;     ("24 slant" "-adobe-courier-medium-o-normal--*-240-*-*-m-*-iso8859-1")
  955. ;     ("8 bold slant" "-adobe-courier-bold-o-normal--*-80-*-*-m-*-iso8859-1")
  956. ;     ("10 bold slant" "-adobe-courier-bold-o-normal--*-100-*-*-m-*-iso8859-1")
  957. ;     ("12 bold slant" "-adobe-courier-bold-o-normal--*-120-*-*-m-*-iso8859-1")
  958. ;     ("14 bold slant" "-adobe-courier-bold-o-normal--*-140-*-*-m-*-iso8859-1")
  959. ;     ("18 bold slant" "-adobe-courier-bold-o-normal--*-180-*-*-m-*-iso8859-1")
  960. ;     ("24 bold slant" "-adobe-courier-bold-o-normal--*-240-*-*-m-*-iso8859-1"))
  961. ;    )
  962. ;  "X fonts suitable for use in Emacs.")
  963. ;
  964. ;(defun mouse-set-font (&rest fonts)
  965. ;  "Select an emacs font from a list of known good fonts"
  966. ;  (interactive
  967. ;   (x-popup-menu last-nonmenu-event x-fixed-font-alist))
  968. ;  (if fonts
  969. ;      (let (font)
  970. ;    (while fonts
  971. ;      (condition-case nil
  972. ;          (progn
  973. ;        (set-default-font (car fonts))
  974. ;        (setq font (car fonts))
  975. ;        (setq fonts nil))
  976. ;        (error
  977. ;         (setq fonts (cdr fonts)))))
  978. ;    (if (null font)
  979. ;        (error "Font not found")))))
  980. (defun mouse-set-font ()
  981.   "Select and set an emacs font from the system list of fonts."
  982.   (interactive)
  983.   (let ((the-font (amiga-popup-font-request)))
  984.     (if the-font
  985.     (amiga-set-font (car the-font) (cdr the-font)))))
  986.  
  987. ;;; Bindings for mouse commands.
  988.  
  989. ;(define-key global-map [down-mouse-1] 'mouse-drag-region) ; CHFIXME: no overlay
  990. (global-set-key [mouse-1]    'mouse-set-point)
  991. (global-set-key [drag-mouse-1]    'mouse-set-region)
  992.  
  993. ;; These are tested for in mouse-drag-region.
  994. (global-set-key [double-mouse-1] 'mouse-set-point)
  995. (global-set-key [triple-mouse-1] 'mouse-set-point)
  996.  
  997. (global-set-key [mouse-2]    'mouse-yank-at-click)
  998. (global-set-key [mouse-3]    'mouse-save-then-kill)
  999.  
  1000. ;; By binding these to down-going events, we let the user use the up-going
  1001. ;; event to make the selection, saving a click.
  1002. ;(global-set-key [C-down-mouse-1]    'mouse-buffer-menu)
  1003. (global-set-key [C-down-mouse-1]    'mouse-set-font)
  1004.  
  1005. ;; Replaced with dragging mouse-1
  1006. ;; (global-set-key [S-mouse-1]    'mouse-set-mark)
  1007.  
  1008. (global-set-key [mode-line mouse-1] 'mouse-select-window)
  1009. (global-set-key [mode-line mouse-2] 'mouse-delete-other-windows)
  1010. (global-set-key [mode-line mouse-3] 'mouse-delete-window)
  1011. (global-set-key [mode-line C-mouse-2] 'mouse-split-window-horizontally)
  1012.  
  1013. ;;
  1014. ;; some old amiga-mouse like bindings
  1015.  
  1016. (defun amiga-mouse-iconify (arg) (amiga-iconify))
  1017.  
  1018. (global-set-key [S-mouse-1] 'mouse-set-mark)
  1019. (global-set-key [C-mouse-1] 'mouse-save-then-kill) ;; CHFIXME ok?
  1020. (global-set-key [M-mouse-2] 'mouse-set-region)
  1021. (global-set-key [S-mouse-2] 'amiga-mouse-iconify)
  1022.  
  1023. (provide 'amiga-mouse)
  1024.  
  1025. ;;; amiga-mouse.el ends here
  1026.